package com.leyou.user.dto;

import com.leyou.common.dto.BaseDTO;
import com.leyou.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author BaiZY on 2020/9/2.
 * @version 1.0
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class UserDTO extends BaseDTO {
    private Integer id;
    private String username;
    private String phone;
    //private String password;

    public UserDTO(BaseEntity entity){
        super(entity);
    }
    public static <T extends BaseEntity>List<UserDTO> convertEntityList(Collection<T> list){
        if (list == null){
            return Collections.emptyList();
        }
        return list.stream().map(UserDTO::new).collect(Collectors.toList());
    }
}
